package homework;

import java.util.ArrayList;
import java.util.List;

public class HomeWork29 {
    public List<List<Integer>> shiftGrid(int[][] grid, int k) {
        int x=grid.length;
        int y=grid[0].length;
        for (int z=0; z < k; z++) {
            int key=grid[x-1][y-1];
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < y; j++) {
                    int tmp=grid[i][j];
                    grid[i][j]=key;
                    key=tmp;
                }
            }
        }
        List<List<Integer>>list=new ArrayList<>();
        for (int i = 0; i <x ; i++) {
            List<Integer>list1=new ArrayList<>();
            for (int j = 0; j <y ; j++) {
                list1.add(grid[i][j]);
            }
            list.add(list1);
        }
        return list;
    }
}
